package com.dhj.interfaceTest;

import java.util.function.IntPredicate;

public class Demo2 {


    public static void main(String[] args) {
        printNum(value -> value % 2 == 0);

        System.out.println("------------------------");
        printNum2(value -> value % 2 == 0, value -> value % 5 == 0);

    }


    public static void printNum(IntPredicate predicate) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i : arr) {
            if (predicate.test(i)) {
                System.out.println(i);
            }
        }
    }


    public static void printNum2(IntPredicate predicate1, IntPredicate predicate2) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i : arr) {
            if (predicate1.and(predicate2).test(i)) {
                System.out.println(i);
            }
        }
    }


}
